﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for ManufacturerBus
/// </summary>
public class ManufacturerBus
{
    ManufarturerDAL ManuDAL;
	public ManufacturerBus()
	{
        ManuDAL = new ManufarturerDAL();
	}
    public string InsertUpdateManufacturer(Manufacturer manu)
    {
        if (ManuDAL.InsertUpdateManufacturer(manu) != 0) 
        {
            return "Add Manufacturer Successful";
        }
        else
        {
            return "Add Manufacturer Fail";
        }
    }

    public int DeleteManuFactureBU(int id)
    {
        Manufacturer manu = new Manufacturer();
        manu.Manufacturer_id = id;
        return ManuDAL.DeleteManuFactureDAL(manu);
    }
    public DataTable getAllManufacturer()
    {
        return ManuDAL.getAllManufacturer();
    }
    public DataTable getManufacturerByID(int manu_id)
    {
        DataTable dt = new DataTable();
        dt = ManuDAL.getManufacturerByID(manu_id);
        
        return dt;
    }
    public Manufacturer getManufacturerByName(string name) 
    {
        DataTable dt = new DataTable();
        dt = ManuDAL.getManufacturerByName(name);
        Manufacturer manu = new Manufacturer();
        manu.Manufacturer_id = Convert.ToInt32(dt.Rows[0][0].ToString());
        manu.Name = dt.Rows[0][1].ToString();
        manu.Image = dt.Rows[0][2].ToString();
        return manu;
    }
}